home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / libg_261.zip / libg_261 / libg++ / src / gen / XPQueue.hP < prev    next >
Text File  |  1992-04-14  |  2KB  |  115 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.     based on code by Marc Shapiro (shapiro@sor.inria.fr)
  6.  
  7. This file is part of the GNU C++ Library.  This library is free
  8. software; you can redistribute it and/or modify it under the terms of
  9. the GNU Library General Public License as published by the Free
  10. Software Foundation; either version 2 of the License, or (at your
  11. option) any later version.  This library is distributed in the hope
  12. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  13. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  14. PURPOSE.  See the GNU Library General Public License for more details.
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20.  
  21. #ifndef _<T>XPQueue_h
  22. #ifdef __GNUG__
  23. #pragma interface
  24. #endif
  25. #define _<T>XPQueue_h
  26.  
  27. #include "<T>.XPlex.h"
  28. #include "<T>.Queue.h"
  29.  
  30. class <T>XPQueue : public <T>Queue
  31. {
  32. protected:
  33.   <T>XPlex     p;
  34.  
  35. public:
  36.                <T>XPQueue(int chunksize = DEFAULT_INITIAL_CAPACITY);
  37.                <T>XPQueue(const <T>XPQueue& q);
  38.                ~<T>XPQueue();
  39.  
  40.   void          operator = (const <T>XPQueue&);
  41.  
  42.   void          enq(<T&> item);
  43.   <T>           deq();
  44.   <T>&          front();
  45.   void          del_front();
  46.  
  47.   void          clear();
  48.   int           empty();
  49.   int           full();
  50.   int           length();
  51.                
  52.   int           OK();
  53. };
  54.  
  55. inline <T>XPQueue::<T>XPQueue(int chunksize) 
  56.      : p(chunksize) {}
  57. inline <T>XPQueue::<T>XPQueue(const <T>XPQueue& q) : p(q.p) {}
  58.  
  59. inline <T>XPQueue::~<T>XPQueue() {}
  60.  
  61. inline void <T>XPQueue::enq(<T&>item)
  62. {
  63.   p.add_high(item);
  64. }
  65.  
  66. inline <T> <T>XPQueue::deq()
  67. {
  68.   <T> res = p.low_element();
  69.   p.del_low();
  70.   return res;
  71. }
  72.  
  73. inline <T>& <T>XPQueue::front()
  74. {
  75.   return p.low_element();
  76. }
  77.  
  78.  
  79. inline void <T>XPQueue::del_front()
  80. {
  81.   p.del_low();
  82. }
  83.  
  84. inline void <T>XPQueue::operator =(const <T>XPQueue& s)
  85. {
  86.   p.operator = (s.p);
  87. }
  88.  
  89. inline int <T>XPQueue::empty()
  90. {
  91.   return p.empty();
  92. }
  93.  
  94. inline int <T>XPQueue::full()
  95. {
  96.   return p.full();
  97. }
  98.  
  99. inline int <T>XPQueue::length()
  100. {
  101.   return p.length();
  102. }
  103.  
  104. inline int <T>XPQueue::OK()
  105. {
  106.   return p.OK();
  107. }
  108.  
  109. inline void <T>XPQueue::clear()
  110. {
  111.   p.clear();
  112. }
  113.  
  114. #endif
  115.